package com.devilvan.betrice.recruitment.controller;

import com.alibaba.fastjson.JSONObject;
import com.devilvan.betrice.recruitment.component.BossRedisHelper;
import com.devilvan.betrice.recruitment.po.BossSkillPo;
import com.devilvan.betrice.recruitment.service.BossJobService;
import com.devilvan.betrice.recruitment.service.BossSkillService;
import com.devilvan.betrice.recruitment.vo.BossJobVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Evad.Wu
 * @Description 招聘信息 控制类
 * @date 2022-08-03
 */
@Slf4j
@RestController
@RequestMapping(value = "/recruitmentController")
@Tag(name = "招聘信息 控制类")
@SuppressWarnings(value = "unused")
public class BossJobController {
    @Resource(name = "bossRedisHelper")
    private BossRedisHelper bossRedisHelper;

    @Resource(name = "bossJobServiceImpl")
    private BossJobService bossJobService;
    @Resource(name = "bossSkillServiceImpl")
    private BossSkillService bossSkillService;

    @Operation(summary = "请求Boss直聘数据")
    @GetMapping(value = "doBoss")
    public void doBoss(@RequestBody String request) {
        JSONObject zpData = JSONObject.parseObject(request).getJSONObject("zpData");
        List<BossJobVo> bossJobVoList = zpData.getJSONArray("jobList").toJavaList(BossJobVo.class);
        bossJobService.doBoss(bossJobVoList);
    }

    @Operation(summary = "查询所有技能信息对象")
    @GetMapping(value = "findBySkillIn")
    public void findBySkillIn(@RequestBody @NonNull List<String> request) {
        Set<BossSkillPo> bossSkillPoSet = bossSkillService.findBySkillIn(new HashSet<>(request));
        for (BossSkillPo bossSkillPo : bossSkillPoSet) {
            System.out.println(bossSkillPo);
        }
    }
}
